-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cw-context): encoding, decoding and iteration of ConsensusState
heights
#1176
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1176 +/- ##
==========================================
- Coverage 64.39% 64.35% -0.04%
==========================================
Files 230 229 -1
Lines 22053 22081 +28
==========================================
+ Hits 14201 14211 +10
- Misses 7852 7870 +18 ☔ View full report in Codecov by Sentry. |
ConsensusState
heights
Looks like this fixed CI on informalsystems/hermes#3943, not seeing the error anymore even with super short trusting period 🚀 |
ConsensusState
heightsConsensusState
heights
- [ibc-clients/cw-context] Fix `ConsensusState` height iteration. | ||
([\#1175](https://github.com/cosmos/ibc-rs/issues/1175)) | ||
- [ibc-clients/cw-context] Encode and decode `ConsensusState` heights using | ||
Protobuf. ([\#1176](https://github.com/cosmos/ibc-rs/pull/1176)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this crate has recently been added (Not present in any versions yet), not sure if we should reflect this fix in the changelog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I didn't know this convention. Removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for handling this, @rnbguy! I left a few comments. It would be great if we could reproduce the issue with a unit test, but let's put that off for now. Otherwise, everything looks good.
pub const CONSENSUS_STATE_HEIGHT_MAP: Map<'_, (u64, u64), Empty> = | ||
Map::new(ITERATE_CONSENSUS_STATE_PREFIX); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started using this for a better interface. I am curious - if anything breaks if I do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized in the old implementation, we should have used this range_with_prefix
from cw-storage-plus. Note the trick for None
and exclusive or inclusive cases in calc_start_bound
and calc_end_bound
.
Since this brings cw-storage-plus
dependency anyway, it's best to use their storage abstractions, built on top of these low-level functions.
for (rev_number, rev_height) in iterator { | ||
let height = Height::new(rev_number, rev_height)?; | ||
|
||
for (key, height) in iterator { | ||
metadata.push(GenesisMetadata { key, value: height }); | ||
metadata.push(GenesisMetadata { | ||
key: iteration_key(rev_number, rev_height), | ||
value: height.encode_vec(), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of passing Height
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for the why, haven’t had a chance yet to explore where/how this GenesisMetaData
gonna be used. But the implementation mirrors ibc-go.
fd7b3db
to
6dc68cf
Compare
I will merge this after confirming the latest changes on the Hermes PR 🎉 |
Tested on personal fork of Note: once hermes is released with wasm client support. basecoin-rs should have an e2e test for wasm clients. |
… heights (#1176) * only consider ITERATE_CONSENSUS_STATE_PREFIX keys * use proto codec * refactor with updated parse_height type sig * encode and decode height funcs * fix clippy * rm redundant type annotation * add changelog entry * correct link on changelog * rm changelog entry * handle missing case * use cw_storage_plus::Map * store or delete height keys at cw_storage_plus::Map * use cw_storage_plus::Map range or keys * rm redundant encode_height and decode_height * add comment * use imports * cargo format * deserialized result must be handled * update doc string
Closes: #1175
This PR also replaces string formatting and parsing with protobuf encoding and decoding.
Description
PR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.